<template>
    <div class="home body">
        <div class="lef">
            <Swiper :group="bannerGroup" />

            <div class="hot_head">
                <ul>
                    <li
                        v-for="(item, index) in hot_head_list"
                        :key="index"
                        @click="order_by_desc = item.order_by_desc"
                        :class="
                            order_by_desc === item.order_by_desc
                                ? 'hotactive'
                                : ''
                        "
                    >
                        <span>{{ item.text }}</span>
                        <img
                            v-show="order_by_desc === item.order_by_desc"
                            src="../assets/img/i_img_right+.png"
                            alt=""
                        />
                    </li>
                </ul>
            </div>

            <List :order_by_desc="order_by_desc" :type="'hostlist'" />
        </div>
        <div class="rig">
            <Hotside />
            <Special />
            <Active />
        </div>
        <SiderBar />
    </div>
</template>

<script>
import Swiper from '../components/Swiper';
import List from '../components/List';
import Special from '../components/Special';
import Active from '../components/Active';
import Hotside from '../components/Hotside';
import SiderBar from '../components/SiderBar';

// import { axiosGet } from '../server/axios';

export default {
    name: 'HomeView',
    components: {
        Swiper,
        List,
        Special,
        Active,
        SiderBar,
        Hotside,
    },
    data() {
        return {
            // 热榜
            order_by_desc: '',
            hot_head_list: [
                {
                    text: '人气榜',
                    order_by_desc: 'hot_score',
                },
                {
                    text: '评论榜',
                    order_by_desc: 'comment_count',
                },
                {
                    text: '收藏榜',
                    order_by_desc: 'favorite_count',
                },
            ],

            bannerGroup: 'article_hot', // banner类型

            // 列表相关
            li_type: 'channel',
            li_id: '',
        };
    },
    watch: {},
    mounted() {
        if (this.$router.history.current.query.id) {
            this.order_by_desc = this.$router.history.current.query.id;
        } else {
            this.order_by_desc = 'hot_score';
        }
    },
    methods: {},
};
</script>

<style scoped lang="scss">
.home {
    width: 1200px;
    margin: 20px auto 50px;
    overflow: hidden;
}
.lef {
    float: left;
    width: 770px;
    overflow: hidden;
    box-shadow: 0 0 8px 4px #f5f5f5;
    margin-bottom: 8px;
}
.rig {
    width: 410px;
    float: right;
    overflow: hidden;
    box-shadow: 0 0 8px 4px #f5f5f5;
    margin-bottom: 8px;
}

.li_header {
    margin-top: 10px;
    background: #fafafa;
    border-radius: 4px;
    padding: 0 12px;
    display: flex;
    align-items: flex-end;
    height: 60px;
    position: relative;
    z-index: 500;

    dl {
        font-size: 18px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #262626;
        width: 100%;

        dt {
            width: 74px;
            height: 36px;
            background: rgba(254, 240, 243, 0.8);
            border-radius: 4px;
            color: #e60012;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            float: right;
            cursor: pointer;
        }
    }
    .ddactive {
        background: rgba(254, 240, 243, 0.8);
        border-radius: 4px;
        color: #e60012;
        font-size: 20px;
    }

    dd {
        // margin: 0 20px;
        position: relative;
        cursor: pointer;
        padding: 0 12px;
        margin: 0 5px;
        float: left;
        height: 42px;
        line-height: 42px;

        img {
            position: absolute;
            top: 8px;
            right: 3px;
        }
    }
    .li_headermore {
        background: #fafafa;
        position: absolute;
        left: 0;
        top: 60px;
        width: 100%;
        z-index: 400;
        padding: 0 12px;

        dl {
        }
    }
    .animated {
        -webkit-animation-duration: 0.5s;
        animation-duration: 0.5s;
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
    }
    @-webkit-keyframes fadeInDown {
        0% {
            opacity: 0;
            -webkit-transform: translate3d(0, -50%, 0);
            transform: translate3d(0, -50%, 0);
        }

        to {
            opacity: 1;
            -webkit-transform: none;
            transform: none;
        }
    }

    @keyframes fadeInDown {
        0% {
            opacity: 0;
            -webkit-transform: translate3d(0, -50%, 0);
            transform: translate3d(0, -50%, 0);
        }

        to {
            opacity: 1;
            -webkit-transform: none;
            transform: none;
        }
    }

    .fadeInDown {
        -webkit-animation-name: fadeInDown;
        animation-name: fadeInDown;
    }
    @-webkit-keyframes fadeOutUp {
        0% {
            opacity: 1;
        }

        to {
            opacity: 0;
            -webkit-transform: translate3d(0, -100%, 0);
            transform: translate3d(0, -100%, 0);
        }
    }

    @keyframes fadeOutUp {
        0% {
            opacity: 1;
        }

        to {
            opacity: 0;
            -webkit-transform: translate3d(0, -100%, 0);
            transform: translate3d(0, -100%, 0);
        }
    }

    .fadeOutUp {
        -webkit-animation-name: fadeOutUp;
        animation-name: fadeOutUp;
    }
}

.hot_head {
    height: 60px;
    background: #fafafa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 18px;
    margin-top: 10px;

    ul {
        width: 100%;
        .hotactive {
            background: #fef0f3;
            font-size: 20px;
            color: #e60012;
        }
        li {
            float: left;
            width: 94px;
            height: 36px;

            opacity: 0.8;
            border-radius: 4px;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-right: 15px;
            font-size: 18px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #262626;
            cursor: pointer;

            img {
                position: absolute;
                top: 8px;
                right: 3px;
            }
        }
    }
}
</style>
